//@version=5
indicator(title="ISTERNET_STR2- MFI-Vortex-RSI-StochRSI-Wt_Cross ", overlay=false, format=format.price, precision=2, timeframe="", timeframe_gaps=true)

//=========== MFI ===============================
length = input.int(title="Length", defval=14, minval=1, maxval=2000,group="MFI Ayarları")
src = hlc3
mf = ta.mfi(src, length)
plot(mf+500, "MFI", color=#7E57C2)
overbought=hline(580, title="MFI 80", color=#787B86)
hline(550, "MFI 50", color=color.new(#787B86, 50))
oversold=hline(520, title="MFI 20", color=#787B86)
fill(overbought, oversold, color=color.rgb(189, 185, 196, 90), title="MFI")

//============== RSI HLİNE ================================
wr = hline(500, color=color.new(color.black, 0), linestyle=hline.style_solid, linewidth=2)
w1 = hline(570, color=color.new(#8a8e8f, 80))
w2 = hline(550, color=color.new(#8a8e8f, 50))
w3 = hline(520, color=color.new(#8a8e8f, 80))
w4 = hline(400, color=color.new(color.black, 0), linestyle=hline.style_solid)







//=========== RSI =======================
ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Ayarları")
rsiSourceInput = input.source(close, "Source", group="RSI Ayarları")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="RSI Ayarları")
maLengthInput = input.int(14, title="MA Length", group="RSI Ayarları")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="RSI Ayarları")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"
rsiPlot = plot(rsi+200, "RSI", #7E57C2, linewidth=2)
plot(rsiMA+200 , "RSI-based MA", color=color.red, linewidth=1)
rsiUpperBand = hline(270, "RSI Upper Band", color=#787B86)
hline(250, "RSI Middle Band", color=color.new(#8a8e8f, 80))
rsiLowerBand = hline(230, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green)
bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill")
midLinePlot = plot(250, color = na, editable = false, display = display.none)
fill(rsiPlot, midLinePlot, 300, 270, top_color = color.new(color.red, 0), bottom_color = color.new(color.red, 100),  title = "Overbought Gradient Fill")
fill(rsiPlot, midLinePlot, 230,  200,  top_color = color.new(color.green, 100), bottom_color = color.new(color.green, 0),      title = "Oversold Gradient Fill")

//============== RSI HLİNE ================================
hr = hline(300, color=color.new(color.black, 0), linestyle=hline.style_solid, linewidth=2)
h5 = hline(270, color=color.new(#8a8e8f, 80))
h6 = hline(250, color=color.new(#8a8e8f, 50))
h7 = hline(230, color=color.new(#8a8e8f, 80))
h8 = hline(200, color=color.new(color.black, 0), linestyle=hline.style_solid)


//===========Stochastic ===============================
smoothK = input.int(3, "K", minval=1,group="STOCK_RSI Ayarları")
smoothD = input.int(3, "D", minval=1,group="STOCK_RSI Ayarları")
lengthRSI = input.int(14, "RSI Length", minval=1,group="STOCK_RSI Ayarları")
lengthStoch = input.int(14, "Stochastic Length", minval=1,group="STOCK_RSI Ayarları")
srcs = input(close, title="RSI Source",group="STOCK_RSI Ayarları")
rsi1 = ta.rsi(srcs, lengthRSI)
k14 = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d14 = ta.sma(k14, smoothD)
ak=plot(k14 + 100, title='%K', color=color.new(color.green, 0), linewidth=2)
ad=plot(d14 + 100, title='%D', color=color.new(#f94380, 0), linewidth=2)

//============== Stochastic HLİNE ================================
h1s = hline(200, 'stock ayrımı üst',color=color.new(color.black, 0), linestyle=hline.style_solid,  linewidth=2)
h2s = hline(180, 'stock üst', color=color.new(color.red, 0 ), linestyle=hline.style_solid, linewidth=1)
h3s = hline(130, 'stock orta', color=color.new(#5abb5a, 0), linestyle=hline.style_solid, linewidth=1)
h4s = hline(120, 'stock üst', color=color.new(#5abb5a, 0 ), linestyle=hline.style_solid, linewidth=1)
h5s = hline(100, 'stock ayrımı alt',color=color.new(color.black, 0), linestyle=hline.style_solid, linewidth=2)
fill(h2s, h4s, title='Stock-H', color=color.new(#8a8e8f, 95))


//=========== Vortex ===============================
period_ = input.int(14, title="Length", minval=2,group="Vortex")
VMP = math.sum( math.abs( high - low[1]), period_ )
VMM = math.sum( math.abs( low - high[1]), period_ )
STR = math.sum( ta.atr(1), period_ )
VIP =100 * (VMP / STR)
VIM =100 * (VMM / STR)
plot(VIP + 300, title="VI +", color=#2962FF)
plot(VIM + 300, title="VI -", color=#E91E63)


//============= WT CROSS =========================
n1 = input(10, 'Channel Length',group="WT Ayarları")
n2 = input(21, 'Average Length',group="WT Ayarları")
obLevel1 = input(60, 'Over Bought Level 1',group="WT Ayarları")
obLevel2 = input(53, 'Over Bought Level 2',group="WT Ayarları")
osLevel1 = input(-60, 'Over Sold Level 1',group="WT Ayarları")
osLevel2 = input(-53, 'Over Sold Level 2',group="WT Ayarları")
ap = hlc3 
esa = ta.ema(ap, n1) 
d = ta.ema(math.abs(ap - esa), n1) 
ci = (ap - esa) / (0.015 * d) 
tci = ta.ema(ci, n2) 
wt1 = tci
wt2 = ta.sma(wt1, 4)
// Plot colors
col_grow_above = input(#26A69A, "Above   Grow", group="WT Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="WT Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="WT Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="WT Histogram", inline="Below")
plot(0, color=color.new(color.gray, 0))
plot(obLevel1, color=color.new(color.red, 0))
plot(osLevel1, color=color.new(color.green, 0))
plot(obLevel2, color=color.new(color.red, 0))
plot(osLevel2, color=color.new(color.green, 0))
aw=plot(wt1, color=color.new(color.green, 0))
bw=plot(wt2, color=color.new(color.red, 0))
hist = wt1 - wt2
fill (aw, bw, title="bg",color = wt1 >= wt2 ? color.new(color.green,70) : color.new(color.red,70))
a=plot(hist, title="Histogram", style=plot.style_area, color=(hist>=0 ? (hist[1] < hist ? color.new(color.blue,80) : color.new(color.blue,80)) : (hist[1] < hist ? color.new(color.blue,80) : color.new(color.blue,80))))
plot(ta.cross(wt1, wt2) ? wt2 : na, color=color.new(color.black, 0), style=plot.style_circles, linewidth=3)
plot(ta.cross(wt1, wt2) ? wt2 : na, color=wt2 - wt1 > 0 ? color.red : color.lime, style=plot.style_circles, linewidth=3)

